package com.lucy.management.controller;

import com.lucy.management.api.CmsSiteControllerApi;
import com.lucy.management.config.oper.OperLog;
import com.lucy.management.domain.CmsSite;
import com.lucy.management.service.CmsSiteService;
import com.lucy.management.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/cms/site")
public class CmsSiteController implements CmsSiteControllerApi {
    @Autowired
    CmsSiteService cmsSiteService;

    @Override
    @OperLog(operDesc = "查询")
    @PostMapping("/list/{page}/{size}")
    public AjaxResult getSiteList(@PathVariable("page") int page, @PathVariable("size")int size,
                                  @RequestParam(required = false) Map map) {
        return cmsSiteService.getSiteList(page,size,map);
    }

    @Override
    @PostMapping("/get/{id}")
    public AjaxResult getSite(@PathVariable("id") String id) {
        return cmsSiteService.getSite(id);
    }

    @Override
    @PostMapping("/save")
    @OperLog(operDesc = "新增修改站点")
    public AjaxResult saveSite(@RequestBody CmsSite cmsSite) {
        return cmsSiteService.save(cmsSite);
    }

    @Override
    @OperLog(operDesc = "删除站点")
    @PostMapping("/delete")
    public AjaxResult deleteSite(@RequestBody List<String> ids) {
        return cmsSiteService.delete(ids);
    }
}
